Add Descriptor::iter_pk - #823
Conversation
This commit was -not- AI-generated, though probably it should've been.
d3fab75 to
82f86e1
Compare
This one -was- AI-generated, though I reviewed it.
82f86e1 to
aa42cd3
Compare
| use crate::{miniscript, Miniscript, MiniscriptKey}; | ||
|
|
||
| /// Iterator over all the keys in a descriptor. | ||
| pub struct PkIter<'desc, Pk: MiniscriptKey> { |
There was a problem hiding this comment.
This is fine. But Ideally, we want this to be a sum type instead of a product type? But then we get whole loads of matches everywhere?
There was a problem hiding this comment.
The main reason to use a product type was that Taproot descriptors have both single keys and (optionally) a taptree iterator.
And in PkIter::next I have a construction where the taptree iterator yields new Miniscript pkiters.
I can try to refactor this to use a sum type but I think it would result in more repeated/redundant code.
There was a problem hiding this comment.
I can try to refactor this to use a sum type but I think it would result in more repeated/redundant code.
Yeah, that would be messy. Ideally, we want to stick the mantra of "make invalid states unrepresentable"; but it might be overkill for this small change
| use crate::{miniscript, Miniscript, MiniscriptKey}; | ||
|
|
||
| /// Iterator over all the keys in a descriptor. | ||
| pub struct PkIter<'desc, Pk: MiniscriptKey> { |
There was a problem hiding this comment.
I can try to refactor this to use a sum type but I think it would result in more repeated/redundant code.
Yeah, that would be messy. Ideally, we want to stick the mantra of "make invalid states unrepresentable"; but it might be overkill for this small change
|
Let's revisit this after we get rid of the |
aa42cd390a700384902fb932c63c308ee0486272 descriptor: add unit tests for iter_pk (Andrew Poelstra)
523654e78e6ef093211fadf02cbd96823d169801 descriptor: add Descriptor::iter_pk (Andrew Poelstra)
Pull request description:
Fixes #821.
Should backport to 12.x.
ACKs for top commit:
sanket1729:
ACK aa42cd390a700384902fb932c63c308ee0486272
Tree-SHA512: 15a5aa6f6d0d7ea5773cdecd4a67320ee89027eaf178c44ad7e1d1465752eb95d835c3dcf1dbb734302e826deeb13803178c7999e15bce710c5fd4dc31c876d6
Fixes #821.
Should backport to 12.x.